<template>
	<view v-if="orderInfo">
		<view class="content">
			<view class="price">
				<text>￥</text>
				<text>{{ orderInfo.price }}</text>
			</view>
			<view class="name">
				商品名称：{{ orderInfo.orderli[0].name }}
			</view>
			<view class="orderno">
				订单号：{{ orderInfo.orn }}
			</view>
			<view class="footer">
				<view class="footer_1" @tap="opens">
					跳转到微信支付
				</view>
				<view class="footer_2" @tap="sure">
					检测支付状态
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import QRCode from 'qrcode'
	// var QRCode = require('@/GraceUI5/js/qrcode.js');
	export default {
		data() {
			return {
				url: '',
				order_id: '',
				status: '',
				imagePath: '',
				qrCodeSrc: '',
				orderInfo: ''
			}
		},
		onLoad(options) {
			this.qrCodeSrc = options.url
			this.order_id = options.order_id
			this.GetoderInfo()
		},
		methods: {
			opens(){ 
				uni.showLoading({
					title:'正在加载'
				})
				this.$http.Post('order/lianjie', {
					order_id: this.order_id
				}, (result) => {
					uni.hideLoading()
					let url = result.data.url_link + '?order_id=' + this.order_id
					location.href= url
				})
			},
			GetoderInfo() { //获取订单信息
				this.$http.Post('order/orderInfo', {
					order_id: this.order_id
				}, (result) => {
					this.orderInfo = result.data
				})
			},
			sure() {
				uni.showLoading({
					title: '正在查询'
				})
				this.$http.Post('index/ordercha', {
					order_id: this.order_id,
				}, (result) => {
					this.status = result.data.status
					if (this.status == 'wei') { //未支付
						uni.showToast({
							title: '您未支付',
							'icon': 'error'
						})
					} else {
						uni.showToast({
							title: '您已支付',
							icon: 'success'
						})
						setTimeout(res => {
							uni.switchTab({
								url: '/pages/order/index?index=0'
							})
						}, 600)
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #1db37c;
	}

	.content {
		width: 100%;
		height: 85vh;
		background-color: #fff;
		position: absolute;
		bottom: 0;
		border-radius: 30rpx 30rpx 0 0;
	}
	
	.footer{
		width: 90%;
		height: 200rpx;
		position: absolute;
		bottom: 100rpx;
		margin-left: 5%;
	}
	
	.footer_1{
		width: 100%;
		height: 85rpx;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		color: #fff;
		background-color: #1db37c;
	}
	
	.footer_2{
		margin-top: 35rpx;
		width: 100%;
		height: 85rpx;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		color: #fff;
		background-color: #3dc9f3;
	}

	.price {
		width: 90%;
		margin: 40rpx auto 20rpx auto;
		font-size: 52rpx;
	}
	
	.name{
		width: 90%;
		margin: 40rpx auto 20rpx auto;
	}
	
	.orderno{
		width: 90%;
		margin: 40rpx auto 20rpx auto;
	}

	.title {
		margin: 20rpx auto;
		width: 96%;
		height: 90rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
	}

	.payimg {
		width: 100%;
		height: 500rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.payimg>image {
		width: 450rpx;
		height: 450rpx;
	}

	.payimg>img {
		width: 450rpx;
		height: 450rpx;
	}

	.paybtn {
		width: 94%;
		height: 100rpx;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.btn1 {
		width: 49%;
		height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #ff5502;
		border-radius: 999rpx;
		border: 1rpx solid #ff5502;
		font-size: 28rpx;
	}

	.btn2 {
		font-size: 28rpx;
		width: 49%;
		height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		border-radius: 999rpx;
		background-color: #ff5502;
	}
</style>